import { defineStore } from "pinia";
import { cookie } from "@/utils/cookie.js";
import i18n from "@/locale/index";

let timer = null;
export const useLocaleStore = defineStore("locale", {
  state: () => ({
    applicationLocale: cookie.get("applicationLocale") || "",
    nodeVal: cookie.get("token"),
  }),
  actions: {
    SetNodeVal(value) {
      cookie.set("nodeVal", value);
      this.nodeVal = value;
    },
    SetAppLocale(value) {
      cookie.set("applicationLocale", value);
      this.applicationLocale = value;
      uni.setLocale(value);
    
    },
  },
  getters: {
    GETAppLocale: (state) => state.applicationLocale,
    GETNodeVal: (state) => state.nodeVal,
  },
});
